:root {
    --bg: #101b23;
    --bg-soft: #162630;
    --panel: #1b2d37;
    --panel-2: #223842;
    --line: #38505a;
    --text: #f4f4ee;
    --muted: #a9b8bb;
    --teal: #63c7b6;
    --gold: #e4b867;
    --green: #72d2a1;
    --red: #f17e82;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 5%, #23404b 0, transparent 30%),
        radial-gradient(circle at 90% 40%, #30283d 0, transparent 28%),
        var(--bg);
}

button { font: inherit; }

.app-shell {
    width: min(980px, 92%);
    margin: 0 auto;
    padding: 34px 0 60px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 24px;
}

.logo {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid #738d89;
    border-radius: 14px;
    color: var(--teal);
    background: #13252d;
    font-family: Georgia, serif;
    font-size: 20px;
    font-weight: 800;
}

.game-header span {
    color: var(--teal);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .15em;
}

.game-header h1 {
    margin: 2px 0 0;
    font-family: Georgia, serif;
    font-size: clamp(28px, 5vw, 42px);
}

.panel {
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 19px;
    background: linear-gradient(145deg, rgba(28,46,57,.98), rgba(18,34,43,.98));
    box-shadow: 0 22px 55px rgba(0,0,0,.35);
}

.start-screen,
.results {
    max-width: 850px;
    margin: auto;
    text-align: center;
}

.book-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border: 1px solid #796943;
    border-radius: 50%;
    color: var(--gold);
    background: #2d2b23;
    font-family: Georgia, serif;
    font-size: 25px;
    font-weight: 800;
}

.eyebrow {
    color: var(--gold);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .16em;
}

.start-screen h2,
.results h2 {
    margin: 9px 0;
    font-family: Georgia, serif;
    font-size: clamp(28px, 5vw, 38px);
}

.start-screen > p,
.results > p {
    max-width: 680px;
    margin: 10px auto 22px;
    color: var(--muted);
    line-height: 1.7;
}

.feature-row {
    margin: 24px 0 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.feature-row span {
    padding: 7px 11px;
    border: 1px solid #3a535d;
    border-radius: 999px;
    color: #c8d4d5;
    background: #13252e;
    font-size: 12px;
}

.start-screen h3 { margin-bottom: 13px; }

.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 11px;
}

.level-btn {
    min-height: 130px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid #3b545f;
    border-radius: 13px;
    color: var(--text);
    background: var(--panel-2);
    cursor: pointer;
    transition: .2s ease;
}

.level-btn:hover {
    transform: translateY(-3px);
    border-color: var(--gold);
}

.level-btn.featured {
    border-color: #71623f;
    background: linear-gradient(145deg, #302f29, #20333c);
}

.level-btn small {
    color: var(--gold);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .1em;
}

.level-btn strong {
    font-family: Georgia, serif;
    font-size: 20px;
}

.level-btn span {
    color: var(--muted);
    font-size: 11px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
    margin-bottom: 13px;
}

.stats div {
    padding: 11px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #142630;
}

.stats small,
.result-grid small {
    display: block;
    color: var(--muted);
    font-size: 8px;
    letter-spacing: .12em;
}

.stats strong {
    display: block;
    margin-top: 4px;
}

.progress-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 13px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.progress-track {
    height: 6px;
    overflow: hidden;
    border-radius: 10px;
    background: #0e1d24;
}

#progressFill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--gold));
    transition: width .3s ease;
}

#typeBadge {
    padding: 5px 8px;
    border: 1px solid #3e665f;
    border-radius: 999px;
    color: var(--teal);
    background: #142b2d;
    font-size: 9px;
}

.puzzle-card {
    position: relative;
    min-height: 440px;
    padding-right: 120px;
}

.timer-box {
    position: absolute;
    top: 27px;
    right: 28px;
    width: 70px;
    height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--teal);
    border-radius: 50%;
    background: #102028;
}

.timer-box.warning { border-color: var(--gold); }
.timer-box.danger { border-color: var(--red); }

.timer-box span {
    font-size: 22px;
    font-weight: 900;
}

.timer-box small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 7px;
}

.prompt-label {
    color: var(--teal);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .1em;
}

.puzzle-card h2 {
    min-height: 70px;
    margin: 11px 0 23px;
    font-family: Georgia, serif;
    font-size: clamp(20px, 3vw, 27px);
    line-height: 1.45;
}

.answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.answer-btn {
    min-height: 65px;
    padding: 13px;
    text-align: left;
    border: 1px solid #3e5964;
    border-radius: 10px;
    color: var(--text);
    background: var(--panel-2);
    cursor: pointer;
    transition: .15s ease;
}

.answer-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--teal);
    background: #29434d;
}

.answer-btn:disabled { cursor: default; }
.answer-btn.correct { border-color: var(--green); background: #183a31; color: #bff1d6; }
.answer-btn.wrong { border-color: var(--red); background: #48272d; color: #ffd0d3; }

.hint-box {
    margin-top: 14px;
    padding: 12px 14px;
    border-left: 3px solid var(--gold);
    border-radius: 6px;
    color: #ead6a9;
    background: #302d24;
    line-height: 1.5;
    font-size: 13px;
}

.feedback {
    min-height: 25px;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 750;
    line-height: 1.5;
}

.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }

.actions {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.hint-button,
.next-button {
    padding: 11px 16px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

.hint-button {
    border: 1px solid #536d75;
    color: #d6dfdf;
    background: transparent;
}

.hint-button:disabled { opacity: .5; cursor: default; }

.next-button {
    border: 0;
    color: #171b1c;
    background: var(--gold);
}

.result-icon { margin-bottom: 10px; font-size: 45px; color: var(--gold); }

.result-grid {
    margin: 24px 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
}

.result-grid div {
    padding: 17px 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #13252e;
}

.result-grid strong {
    display: block;
    margin-top: 6px;
    color: var(--gold);
    font-size: 21px;
}

.hidden { display: none !important; }

@media (max-width: 680px) {
    .level-grid { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .progress-row { grid-template-columns: 1fr auto; }
    .progress-track { grid-column: 1 / -1; grid-row: 2; }
    .puzzle-card { padding: 110px 19px 23px; }
    .timer-box { top: 20px; right: 50%; transform: translateX(50%); }
    .answers { grid-template-columns: 1fr; }
    .result-grid { grid-template-columns: repeat(2, 1fr); }
}
